<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户登录</title>
<script language="javascript">
	window.onload = myclothing()
	function myclothing() {
		if(	${clothinglist==null })
			window.location.href = "<c:url value='/ClothingAction?oper=indexlist'/>";
	}
	
	function add(){
		
		alert("请登录后购买");
	}
	
	var currentDate = new Date(
<%=new java.util.Date().getTime()%>
	);
	function run() {
		currentDate.setSeconds(currentDate.getSeconds() + 1);
		document.getElementById("currentTime").innerHTML = currentDate
				.toLocaleString();
	}

	window.setInterval("run();", 1000);

	function changePage(method) {

		var pageNo = document.forms[1].pageNo.value;
		var total = document.forms[1].total.value;
		if (method == "next") {
			if (parseInt(pageNo) >= parseInt(total)) {
				alert("当前已经是最后一页！");
				return false;
			} else {
				document.forms[1].pageNo.value = parseInt(pageNo) + 1;
			}
		}
		if (method == "previous") {
			if (parseInt(pageNo) <= 1) {
				alert("当前已经是第一页");
				return false;
			} else {
				document.forms[1].pageNo.value = parseInt(pageNo) - 1;
			}
		}
		if (method == "first") {
			document.forms[1].pageNo.value = 1;
		}
		if (method == "end") {
			document.forms[1].pageNo.value = total;
		}

		document.forms[1].submit();
	}
</script>
</head>
<body>
	<form action="<c:url value='/UserInfoAction?oper=login'/>" method="post" style="width:">
			 <span style="color:#f00;"> ${msg }</span> 
			<br/>
			<div style="width:100%;height:50px;">
			<div style="width:550px;float:right;">
			<b class="glyphicon glyphicon-user"></b>:<input type="text" name="user_account" placeholder="在此输入账户"> 
			<b class="glyphicon glyphicon-lock"></b>:<input type="password" name="user_password" placeholder="在此输入密码">
			<input type="submit" value="登录" class="btn btn-default"> 
			<a href="<c:url value='/UserInfoAction?oper=sign'/>" class="btn btn-success">注册</a>
			</div>
			</div>
	</form>

   <form action="<c:url value='/ClothingAction?oper=indexlist'/>" method="post" class="bs-example bs-example-form" role="form">
   <input type="hidden" name="pageNo" value="${pageNo}"> 
		<input type="hidden" name="total" value="${total}">
            <div style="width:100%;height:50px;">
            <div style="width:550px;float:right;">
         <div class="col-lg-6">
            <div class="input-group">
               <input type="text" class="form-control"  name="name" value="${name }" placeholder="搜索想要的衣服吧！">
               <span class="input-group-btn">
                  <button class="btn btn-default" type="submit" onclick="changePage('first')">
                    <b class="glyphicon glyphicon-search"></b>
                  </button>
               </span>
            </div><!-- /input-group -->
         </div><!-- /.col-lg-6 -->
         </div>
         </div>
   </form>
	
	
<div style="margin:0 auto;width:800px;">
	
		<c:forEach items="${clothinglist }" var="clothing">
		<div style="float:left;margin-right:100px;text-align: center;">
	<c:choose>
		<c:when test="${empty clothing.picture }">
			
			<a href="<c:url value='/ClothingAction?oper=get&id=${clothing.id }'/>"><img src="images/1.jpg" width="270" height="420" style="float:left;"></a>
			<br/>
		</c:when>
		<c:otherwise>
			<a href="<c:url value='/ClothingAction?oper=get&id=${clothing.id }'/>"><img src="<c:url value="/upload/${clothing.picture}"/>"
				width="270" height="420" style="float:left;"></a>
				<br/>
		</c:otherwise>
	</c:choose>
	
				${clothing.name }
				<br/>
				价格：${clothing.price}￥
				<br/>
				售价：${clothing.saleprice}￥
				<br/>
				${clothing.summary}
				<br/>
		<a href="#" onclick="add()">加入购物车<b class="glyphicon glyphicon-shopping-cart"></b></a>		
	</div>
		
		</c:forEach>
		<div class="clearfix"></div>
	<table style="margin:0 auto;">
		<tr>
			<td colspan="3">查询到：${count}条记录 <a href="#"
				onclick="changePage('first')">首页</a> <a href="#"
				onclick="changePage('previous')">上一页</a> <a href="#"
				onclick="changePage('next')">下一页</a> 第${ pageNo}页/共${total}页 <a
				href="#" onclick="changePage('end')">尾页</a>
			</td>
		</tr>
	</table>
</div>
	<a href="<c:url value='/AdminInfoAction?oper=managelogin'/>">管理员登录</a>
<div id="currentTime"></div>

</body>
</html>